<form action="index.php?app=mobileapi&ctl=admin_sales_ads&act=save"  method="POST" name="gEditor" id="gEditor" >
<input type="hidden" name="ad_id" value="<{$adInfo.ad_id}>">
<div class="tableform">
<div class="division">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
  <th><{t}>广告名称：<{/t}></th>
  <td><{input type="text" name="ad_name" style="width:120px" vtype="required" value=$adInfo.ad_name}><em><font color='red'>*</font></em></td>
</tr>
<tr>
  <th><{t}>关联商品：<{/t}></th>
    <td>
        <{input type="object" name="ad_url" object="goods" app="b2c" select="radio" vtype="required" textcol="name" cols="name" filter="goods_type=normal&marketable=true"  multiple="true" value=$adInfo.ad_url}>
        <input name="url_type" value="goods" type="hidden"/>
    </td>
  <!--td><{input type="text" name="ad_url" style="width:120px" vtype="required" value=$adInfo.ad_url}><em><font color='red'>*</font></em></td-->
</tr>
<!--tr>
  <th><{t}>链接类型：<{/t}></th>
  <td>
    <select name="url_type" id="url_type">
         <option value='goods' <{if $adInfo.url_type == 'goods'}>selected<{/if}> ><{t}>精选商品<{/t}></option>
         <option value='cat' <{if $adInfo.url_type == 'cat'}>selected<{/if}> ><{t}>分类<{/t}></option>
         <option value='virtual_cat' <{if $adInfo.url_type == 'virtual_cat'}>selected<{/if}> ><{t}>虚拟分类<{/t}></option>
         <option value='article' <{if $adInfo.url_type == 'article'}>selected<{/if}> ><{t}>文章<{/t}></option>
         <option value='none' <{if $adInfo.url_type == 'none'}>selected<{/if}> ><{t}>不链接<{/t}></option>
    </select>
  </td>
</tr-->
<tr>
  <th><{t}>广告图片<{/t}></th>
  <td>
  <{input type="image" name="ad_img" value=$adInfo.ad_img width=160 height=90}>请上传广告图片</td>
</tr>
<!--tr>
  <th><{t}>图片宽：<{/t}></th>
  <td><{input type="text" name="ad_img_w" style="width:120px" vtype="required" value=$adInfo.ad_img_w}><em><font color='red'>*</font></em></td>
</tr>
<tr>
  <th><{t}>图片高：<{/t}></th>
  <td><{input type="text" name="ad_img_h" style="width:120px" vtype="required" value=$adInfo.ad_img_h}><em><font color='red'>*</font></em></td>
</tr>
<tr>
  <th><{t}>失效：<{/t}></th>
  <td><input type="radio" name="disabled"  <{if $adInfo.disabled == 'true'}>checked="checked"<{/if}> value="true">是 &nbsp;&nbsp; <input type="radio" name="disabled"  <{if $adInfo.disabled == 'false'}>checked="checked"<{/if}> value="false">否</td>
</tr-->
<tr>
  <th><{t}>排序：<{/t}></th>
  <td><{input style="width:50px;" type="unsigned" name="ordernum"  value=$adInfo.ordernum|default:1}>(奇数为大图，偶数为小图)</td>
</tr>
</table>
</div>

<{capture name='footbar'}>
<table cellspacing="0" cellpadding="0" class="table-action">
      <tbody>
		<tr valign="middle">
        <td>
            <{button label=$___b2c="保存并关闭窗口"|t:'b2c' class="btn-primary" onclick="subGoodsForm(event,2)"}>
            <{button label=$___b2c="保存当前"|t:'b2c' class="btn-primary" onclick="subGoodsForm(event,3)"}>
            <{assign var=bcclose value=$___b2c='确定退出?'|t:'b2c'}>
            <{assign var=bclose value="关  闭"}>
            <{button label=$___b2c=$bclose|t:'b2c' class="btn-secondary" onclick="if(confirm('{$bcclose}'))window.close()"}>
        </td>
        </tr>
        </tbody>
</table>
<{/capture}>
</div>
</form>

<script>

   /*
    *  sign:{
          1:保存并增加相似商品,
          2:保存并返回,
          3:保存当前不返回，
    *    }
    */
   var _form=$('gEditor'),_formActionURL=_form.get('action');


   subGoodsForm = function (event,sign){
       var specOBJ='';
       var _target=$(new Event(event).target);

       //var target={extraData:$('finder-tag').toQueryString()+'&'+specOBJ,onRequest:function(){_target.disabled = true;}};
       var target={onRequest:function(){_target.disabled = true;}};

       switch (sign){
            case 1:                    //添加相似
                $extend(target,{
                    onComplete:function(){
                        if(window.opener.finderGroup&&window.opener.finderGroup['<{$env.get.finder_id}>'])
                        window.opener.finderGroup['<{$env.get.finder_id}>'].refresh();
                        clearOldValue();
                        _target.disabled = false;
                }});
            break;
            case 2:                   //保存关闭
                $extend(target,{
                    onComplete:function(rs){
                        if(rs&&!JSON.decode(rs).success){
                            if(window.opener.finderGroup&&window.opener.finderGroup['<{$env.get.finder_id}>']){
                                window.opener.finderGroup['<{$env.get.finder_id}>'].refresh();
                            }
                            window.close();
                        }
                        _target.disabled = false;
                    }}
                );
            break;
            case 3:
                $extend(target,{            //保存当前
                    onComplete:function(rs){
                        
                        if(window.opener.finderGroup&&window.opener.finderGroup['<{$env.get._finder.finder_id}>'])
                        window.opener.finderGroup['<{$env.get._finder.finder_id}>'].refresh();
                        _target.disabled = false;
                    }}
                );
            break;
       }

        _form.store('target',target);
        _form.set('action',_formActionURL+'&but='+sign).fireEvent('submit',new Event(event));
    };

    var clearOldValue=function(){
         
    };
</script>
